package com.ljf.controller;

import com.ljf.dto.EditPswDto;
import com.ljf.service.EmployeeService;
import com.ljf.util.Result;
import com.ljf.vo.InformationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ljf.annotation.HasPermission;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/personal")
public class PersonalController {

    @Autowired
    private EmployeeService employeeService;

    /**
     * 查询用户详细信息
     * @param request
     * @return
     */
    @HasPermission("personnel_management:employee:update")
    @GetMapping("/information")
    public Result information(HttpServletRequest request){
        String token = request.getHeader("token");
        InformationVo information = employeeService.information(token);
        return Result.success(information);
    }

    /**
     * 修改个人密码
     * @param request
     * @param editPswDto
     * @return
     */
    @HasPermission("personal:edit_pwd")
    @PostMapping("/edit_pwd")
    public Result editpsw(HttpServletRequest request, EditPswDto editPswDto){
        String token = request.getHeader("token");
        employeeService.editPwd(token,editPswDto);
        return Result.success();
    }


}
